import pandas as pd

from logic.config import Config
import sqlite3

class SqliteMgr:
    def __init__(self):
        self.db = Config.get_config_path() +'/data.db'
        self.conn = sqlite3.connect(self.db)

    def df_2_db(self, df, tb):
        df.to_sql(tb, self.conn, if_exists='replace', index=False)

    def db_2_df(self,sql):
        df = pd.read_sql(sql, self.conn)
        return df

    def execute(self, sql):
        return self.conn.execute(sql)

